home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).adf / PCQ / Runtime / memory.asm < prev    next >
Assembly Source File  |  1989-03-31  |  2KB  |  66 lines

  1.  
  2. *    Memory.asm (of PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4.  
  5. *    This file takes care of new() and dispose().  Note that new()
  6. *    uses AllocRemember() so we can keep track of our allocations.
  7. *    Dispose must, therefore, remove the deallocated node from our
  8. *    allocation list.  That's why it's a lot more complex than new()
  9.  
  10.     SECTION    ONE
  11.  
  12.     XREF    _p%IntuitionBase
  13.     XREF    _LVOAllocRemember
  14.     XREF    _AbsExecBase
  15.     XREF    _LVOFreeMem
  16.     XREF    _p%exit
  17.  
  18.     XDEF    newkey
  19.  
  20.     XDEF    _p%new
  21. _p%new
  22.  
  23.     move.l    #$00010001,d1
  24.     lea    newkey,a0
  25.     move.l    _p%IntuitionBase,a6
  26.     jsr    _LVOAllocRemember(a6)
  27.     tst.l    d0
  28.     beq.s    1$
  29.     rts
  30. 1$    move.l    #50,d0
  31.     jmp    _p%exit
  32.  
  33.     XDEF    _p%dispose
  34. _p%dispose
  35.  
  36.     lea    newkey,a1    ; trailer
  37.     move.l    newkey,a0    ; get first remember key
  38.     cmp.l    #0,a0        ; set flags
  39.     beq.s    2$        ; if it's zero, leave
  40. 1$    cmp.l    8(a0),d0    ; is it the right one?
  41.     beq.s    3$        ; if so, leave
  42.     move.l    a0,a1        ; if not, move current to trailer
  43.     move.l    (a0),a0        ; and get next record
  44.     cmp.l    #0,a0        ; set flags
  45.     bne    1$        ; if it's not zero, keep going
  46. 2$    rts            ; no such memory exists, so leave
  47. 3$    move.l    a0,-(sp)    ; free the memory.  First, save pointer
  48.     move.l    (a0),a2        ; get next pointer
  49.     move.l    a2,(a1)        ; save it in previous (link)
  50.  
  51.     move.l    8(a0),a1    ; get address of block
  52.     move.l    4(a0),d0    ; and size
  53.     move.l    _AbsExecBase,a6
  54.     jsr    _LVOFreeMem(a6)    ; free the memory block
  55.  
  56.     move.l    (sp)+,a1    ; get the pointer back
  57.     move.l    #12,d0        ; it's this long
  58.     move.l    _AbsExecBase,a6
  59.     jsr    _LVOFreeMem(a6)    ; free the remember block
  60.  
  61.     rts            ; return
  62.  
  63.     SECTION    TWO
  64. newkey    dc.l    0
  65.     END
  66.